package chapter3.homework;

/**
 * 斐波那契数列：求斐波那契数列中第 n 个元素的值是多少?
 *
 * @author 张玮婷 20245080902061
 */

public class Fibonacci {
    public static void main(String[] args) {
        int n = 11;
        int number1 = 0;
        int number2 = 1;
        int result=0;
            for (int i = 2; i < n; i++) {
               result = number1 + number2;
               number1=number2;
               number2=result;
            }
                if(n==1){
                    result=number1;
            }
                else if(n==2){
                    result=number2;
        }
                System.out.println("第11个元素是"+result);
    }
}
